cmake_minimum_required(VERSION 3.5)
project(jetson_dec)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
link_directories("/usr/lib/aarch64-linux-gnu/")
link_directories("/usr/lib/aarch64-linux-gnu/tegra")
link_directories("/usr/local/lib")

#include_directories(include)
include_directories(".")
include_directories("/usr/local/include")

find_library(avformat libavformat.a REQUIRED)
find_library(avcodec libavcodec.a REQUIRED)
find_library(avutil libavutil.a REQUIRED)
find_library(swscale libswscale.a REQUIRED)
find_library(avfilter libavfilter.a REQUIRED)
find_library(swresample libswresample.a REQUIRED)
find_library(lzma liblzma.so REQUIRED)
find_library(bz2 libbz2.so REQUIRED)
find_library(pthread libpthread.so REQUIRED)
#find_library(va libva.so REQUIRED)
find_library(drm libdrm.so REQUIRED)
#find_library(va-x11 libva-x11 REQUIRED)
#find_library(X11 libX11.so REQUIRED)
find_library(v4l2 libv4l2.so REQUIRED)
#find_library(nvv4l2 libnvv4l2.so REQUIRED)
find_library(x264 libx264.a REQUIRED)
find_library(libnvbuf_utils.so REQUIRED)

add_executable(decoder src/h264_dec.cpp src/decoder_node.cpp)
ament_target_dependencies(decoder rclcpp sensor_msgs)

target_link_libraries(
	decoder
	${avfilter}
	${avformat}
	${avcodec}
	${avutil}
	${swresample}
	${swscale}
	${lzma}
	${bz2}
	${pthread}
#	${va}
#	${va-x11}
	${drm}
	${X11}
	${v4l2}
#	${nvv4l2}
	${x264}
	libnvbuf_utils.so
)

install(
	TARGETS decoder
	DESTINATION lib/${PROJECT_NAME}
)

install(
	DIRECTORY launch
	DESTINATION share/${PROJECT_NAME}
)


ament_package()
